import request from '@/utils/request'

const userApi = {
  AccountLogin: '/admin/admin_user/login',
  CaptchaLogin: '/admin/admin_user/login_by_captcha',
  Logout: '/auth/logout',
  ForgePassword: '/auth/forge-password',
  Register: '/auth/register',
  twoStepCode: '/auth/2step-code',
  SendSms: '/account/sms',
  SendSmsErr: '/account/sms_err',
  UserInfo: '/admin/admin_user/info',
  UserMenu: '/user/nav',
  MobileCaptcha: '/admin/captcha/alisms',
  FeiShuCaptcha: '/admin/captcha/feishu'
}

const env = process.env.VUE_APP_CENTER_API

/**
 * @description 登录
 * @param parameter
 * @returns {*}
 */
export function login (parameter) {
  return request({
    url: env + '/admin/admin_user/login_by_captcha',
    method: 'post',
    data: parameter
  })
}

/**
 * @description 获取验证码
 * @param parameter
 * @returns {*}
 */
export function getCaptcha (parameter) {
  const Api = parameter.type === 'tab1' ? '/admin/captcha/feishu' : '/admin/captcha/alisms'
  return request({
    url: env + Api,
    method: 'post',
    data: { username: parameter.account }
  })
}

export function getInfo (parameter) {
  // console.info(process.env.VUE_APP_CENTER_API + userApi.UserInfo,'111')
  return request({
    url: process.env.VUE_APP_CENTER_API + userApi.UserInfo,
    method: 'post',
    data: { system_alias: parameter }
  })
}



export function logout () {
  return request({
    url: userApi.Logout,
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
